<template>
    <div>
        <NavBar :title="title"></NavBar>
        <van-address-list v-model="chosenAddressId" :list="list" :disabled-list="disabledList" default-tag-text="默认"
            @add="onAdd" @edit="onEdit" add-button-text="去支付" />
        <van-cell-group inset>
            <van-cell title="单元格" :value="getOrderApiData.orderId" />
            <van-cell title="单元格" :value="getOrderApiData.create_time" />
            <van-cell title="单元格" :value="getOrderApiData.product_code" />
            <van-cell title="单元格" :value="(getOrderApiData.totalPrice/100) + '元'" />


        </van-cell-group>

    </div>
</template>

<script setup>
import NavBar from '@/components/NavBar.vue';
const title = '订单'
import { useRoute, useRouter } from 'vue-router';
const route = useRoute()
const router = useRouter()
console.log(route.params.orderId);
import { ref } from 'vue';

const getOrderApiData = ref([])
import { getOrderApi } from '@/api/api';
getOrderApi(route.params.orderId).then(res => {
    console.log(res);
    getOrderApiData.value = res.data.data
    console.log(getOrderApiData.value);
    payData.value = {
        orderId:res.data.data.orderId,
        subject:res.data.data.product_code,
        totalPrice:res.data.data.totalPrice/1000,
    }
})
const chosenAddressId = ref('1');
const list = [
    {
        id: '1',
        name: localStorage.getItem('username1') ? localStorage.getItem('username1') : '张三',
        tel: localStorage.getItem('username'),
        address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
        isDefault: true,
    },]
import { payApi } from '@/api/api';
let payData = ref([])

const onAdd = () => {
    payApi(payData.value).then(res => {
        
        console.log('支付接口',res);
        window.open(res.data.data, '_blank')
    })
}

</script>

<style lang="scss" scoped></style>